#pragma once

#include  "iostream"
#include  "vector"
#include  "stack"
#include  "unordered_map"
#include   "queue"

using namespace std;

// 这个是抄程序员KAER视频的
vector<int> partitionLabels(string s) {


    vector<int> ret;

    int arr[27] = {0};//存储最晚出现的下标

    for (int i = 0; i < s.size(); ++i) {
        arr[s[i] - 'a'] = i;
    }

    //开始遍历存储不会重复出现字符的区间
    int startIndex = 0;
    int right = 0;

    for (int i = 0; i < s.size(); ++i) {

        right = max(right, arr[s[i] - 'a']);

        if (right == i) {
            //说明找到了一个区间
            ret.push_back(right - startIndex + 1);
            startIndex = i + 1;
        }

    }

    return ret;


}